How to use CC_MD5 method in swift language

This is what I came up with. It’s an extension to String. Don’t forget to add #import <CommonCrypto/CommonCrypto.h> to the ObjC-Swift bridging header that Xcode creates. extension String { var md5: String! { let str = self.cStringUsingEncoding(NSUTF8StringEncoding) let strLen = CC_LONG(self.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)) let digestLen = Int(CC_MD5_DIGEST_LENGTH) let result = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLen) CC_MD5(str!, strLen, result) let hash = … Read more

MD5 hash from file in C++

Here’s a straight forward implementation of the md5sum command that computes and displays the MD5 of the file specified on the command-line. It needs to be linked against the OpenSSL library (gcc md5.c -o md5 -lssl) to work. It’s pure C, but you should be able to adapt it to your C++ application easily enough. … Read more

Check if http request comes from my android app

One of basic rules of security is: you don’t trust client data. Ever. You should consider your app decompiled, all “secret” keys known to attacker, etc. You can, however, hinder attacker’s attempts to forge your requests. Sending (and verifying) checksum of your request is one of methods (your idea of MD5(secret_key + params)). You could … Read more

How do I hash a string with Delphi?

If you want an MD5 digest and have the Indy components installed, you can do this: uses SysUtils, IdGlobal, IdHash, IdHashMessageDigest; with TIdHashMessageDigest5.Create do try Result := TIdHash128.AsHex(HashValue(‘Hello, world’)); finally Free; end; Most popular algorithms are supported in the Delphi Cryptography Package: Haval MD4, MD5 RipeMD-128, RipeMD-160 SHA-1, SHA-256, SHA-384, SHA-512, Tiger Update DCPCrypt is … Read more

php: number only hash?

An MD5 or SHA1 hash in PHP returns a hexadecimal number, so all you need to do is convert bases. PHP has a function that can do this for you: $bignum = hexdec( md5(“test”) ); or $bignum = hexdec( sha1(“test”) ); PHP Manual for hexdec Since you want a limited size number, you could then … Read more