SHA1 hashing in SQLite: how?

There is no such function built into SQLite3. But you could define a user function e.g. with sqlite3_create_function if you’re using the C interface, and implement SHA-1 with that. (But if you’re having a programmable interface perhaps you could just SHA-1 the password outside of the SQL engine.) You could also try to find / … Read more

What does “Not LTV-enabled” mean?

LTV (Long Term Validation) and PDF signatures The term LTV-enabled 4 Profile for PAdES-LTV 4.1 Overview Validation of an electronic signature requires data to validate the signature such as CA certificates, Certificate Revocation List (CRLs) or Certificate status information (OCSP) commonly provided by an online service (referred to in the present document as validation data). … Read more

Is it possible to encrypt data with AES (256 bit) GCM mode in .net framework 4.7?

This answer reflects the comments from Luke Park, bartonjs, Timo, aand Maarten Bodewes above. One option is to use the Bouncycastle C# library, which has its own self-contained implementation of AES as well as the GCM mode. Look at the source code for the classes GCMBlockCipher, AesEngine, and AEADParameters. Another option is to use P/Invoke … Read more

PyCrypto problem using AES+CTR

The counter must return the same on decryption as it did on encryption, as you intuit, so, one (NOT SECURE AT ALL) way to do it is: >>> secret = os.urandom(16) >>> crypto = AES.new(os.urandom(32), AES.MODE_CTR, counter=lambda: secret) >>> encrypted = crypto.encrypt(“aaaaaaaaaaaaaaaa”) >>> print crypto.decrypt(encrypted) aaaaaaaaaaaaaaaa CTR is a block cipher, so the “16-at-a-time” constraint … Read more

Load an PEM encoded X.509 certificate into Windows CryptoAPI

KJKHyperion said in his answer: I discovered the “magic” sequence of calls to import a RSA public key in PEM format. Here you go: decode the key into a binary blob with CryptStringToBinary; pass CRYPT_STRING_BASE64HEADER in dwFlags decode the binary key blob into a CERT_PUBLIC_KEY_INFO with CryptDecodeObjectEx; pass X509_ASN_ENCODING in dwCertEncodingType and X509_PUBLIC_KEY_INFO in lpszStructType … Read more

HMAC SHA256 in Swift 4

If you target iOS 13.0+ or macOS 10.15+, use Apple’s CryptoKit import CryptoKit let secretString = “my-secret” let key = SymmetricKey(data: Data(secretString.utf8)) let string = “An apple a day keeps anyone away, if you throw it hard enough” let signature = HMAC<SHA256>.authenticationCode(for: Data(string.utf8), using: key) print(Data(signature).map { String(format: “%02hhx”, $0) }.joined()) // 1c161b971ab68e7acdb0b45cca7ae92d574613b77fca4bc7d5c4effab89dab67

find certificate on smartcard currently on reader

I am afraid it is not possible to detect if the card containing specific X509Certificate2 object is present in the reader by using standard .NET APIs. The best thing (very hackish) I could come up with is this: public static X509Certificate2 GetDefaultCertificateStoredOnTheCard() { // Acquire public key stored in the default container of the currently … Read more

How to implement Triple DES in C# (complete example)

Complete source here: http://www.codeproject.com/Articles/14150/Encrypt-and-Decrypt-Data-with-C Encrypt: public static string Encrypt(string toEncrypt, bool useHashing) { byte[] keyArray; byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt); System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); // Get the key from config file string key = (string)settingsReader.GetValue(“SecurityKey”, typeof(String)); //System.Windows.Forms.MessageBox.Show(key); //If hashing use get hashcode regards to your key if (useHashing) { MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider(); keyArray … Read more