Sample code for 30+ languages & platforms
Swift

MD4 Hash a String

See more Encryption Examples

MD4 hash a string.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let crypt = CkoCrypt2()!

    var content: String? = "The quick brown fox jumps over the lazy dog"

    // The desired output is a hexidecimal string:
    crypt.encodingMode = "hex"

    // Set the hash algorithm:
    crypt.hashAlgorithm = "md4"

    var hashStr: String?
    hashStr = crypt.hashStringENC(str: content)

    print("\(hashStr!)")

    // The output is:
    // 1BEE69A46BA811185C194762ABAEAE9

}