cryptography

Unhashing a password or holding unhashed password C#

落花浮王杯 提交于 2019-12-25 19:08:13
问题 BACKGROUND I am making a personal password vault. I will be the only one that uses it and maintains it. I am doing it to practice cryptography as a personal project. WHAT WORKS I have a login page which is linked to a "Users" table in the database that stores my username and a password that has been salted and hashed. I have the method that will check what I type in the password field against the hashed/salted password within the database and that all works fine so I can log in successfully.

Azure DocumentDB auth header in R

青春壹個敷衍的年華 提交于 2019-12-25 16:09:00
问题 I'm attempting to generate the Azure documentDB auth header for REST API calls using R instead of the C# and Node.js code snippets provided by Microsoft. I'm specifically running into issues translating this code from Node.js to R: var crypto = require("crypto"); var key = new Buffer(masterKey, "base64"); var text = "helloworld"; var body = new Buffer(text, "utf8"); var signature = crypto.createHmac("sha256", key).update(body).digest("base64"); In this case, masterKey can be assumed to be

Azure DocumentDB auth header in R

流过昼夜 提交于 2019-12-25 16:08:12
问题 I'm attempting to generate the Azure documentDB auth header for REST API calls using R instead of the C# and Node.js code snippets provided by Microsoft. I'm specifically running into issues translating this code from Node.js to R: var crypto = require("crypto"); var key = new Buffer(masterKey, "base64"); var text = "helloworld"; var body = new Buffer(text, "utf8"); var signature = crypto.createHmac("sha256", key).update(body).digest("base64"); In this case, masterKey can be assumed to be

Convert der to pem through bouncy castle library

烂漫一生 提交于 2019-12-25 14:44:23
问题 I found many answers towards convert from pem to der . However, I cannot find ways to convert der to pem . for example, the following codes generates der encoded file pkcs10.cer public static void main(String[] args) throws Exception { X509Certificate[] chain = buildChain(); PEMWriter pemWrt = new PEMWriter(new OutputStreamWriter(System.out)); pemWrt.writeObject(chain[0]); FileWriter fwO = new FileWriter("pkcs10.cer"); fwO.write((chain[0]).toString()); fwO.close(); pemWrt.close(); } Like, [0]

Encrypt file with AES-256 and Decrypt file to its original format

别等时光非礼了梦想. 提交于 2019-12-25 14:13:25
问题 I have to build a project for encryption and decryption of files in AES-256. So, I have to encrypt files and those files could be of any format like text file, image file, video file or any kind of file with any format, And have to encrypt those files and store them on device with different format like *.anuj (extension name). Suppose I encrypted file and made new file with custom extension. While decryption that file how am I supposed to know that original file was text file or image or of

Is there a better way to detect endianness in .NET than BitConverter.IsLittleEndian?

北慕城南 提交于 2019-12-25 11:14:06
问题 It would be nice if the .NET framework just gave functions/methods from the BitConverter class that just explicitly returned an array of bytes in the proper requested endianness. I've done some functions like this in other code, but is there a shorter more direct way? (efficiency is key since this concept is used a TON in various crypto and password derivation contexts, including PBKDF2, Skein, HMAC, BLAKE2, AES and others) // convert an unsigned int into an array of bytes BIG ENDIEN // per

Including Signed Libraries in Executable JAR with Maven

时光毁灭记忆、已成空白 提交于 2019-12-25 09:31:50
问题 Maven shade and assembly plugins first unpack and then add dependencies to the executable jar. This can produce a conflict with Java Cryptography Extension, since the libraries like BouncyCastle should be used in their signed versions. Question: Is there a way to create executable jar with maven in a way that the libraries are included without unpacking? 回答1: The standard classloader will not load classes from another jar, hence the exploded jar. The best way to achieve adding the signed jars

How to overlay images in python

不问归期 提交于 2019-12-25 09:27:41
问题 from PIL import Image import sys infile1 = Image.open(sys.argv[1]) infile2 = Image.open(sys.argv[2]) infile3 = Image.open(sys.argv[3]) infile4 = Image.open(sys.argv[4]) outfile1 = Image.new('1', infile1.size) outfile2 = Image.new('1', infile1.size) outfile3 = Image.new('1', infile1.size) for x in range(infile1.size[0]): for y in range(infile1.size[1]): outfile1.putpixel((x, y), max(infile1.getpixel((x, y)), infile2.getpixel((x, y)))) outfile2.putpixel((x, y), max(infile3.getpixel((x, y)),

Digital signature with CryptVerifySignature

╄→гoц情女王★ 提交于 2019-12-25 08:50:12
问题 I want to implement digital signature app using CryptVerifySignature. I've written this code(with help of MSDN example): #define Check(condition, message) if (!(condition)) { fprintf(stderr, "%s\n", message); goto Exit; }; void DigSign(const char* inputFileName, const char* signFileName) { HCRYPTPROV hProv; BYTE *pbBuffer= NULL; DWORD dwBufferLen = 0; HCRYPTHASH hHash; HCRYPTKEY hKey; HCRYPTKEY hPubKey; BYTE *pbKeyBlob; BYTE *pbSignature; DWORD dwSigLen; DWORD dwBlobLen; FILE* inputFile =

In OAuth: use MAC-SHA1 or RSA-SHA1?

一笑奈何 提交于 2019-12-25 08:30:55
问题 Concerning OAuth, what is the most suitable cryptography/encryption method to use HMAC-SHA1 or RSA-SHA1 ? Thanks. 回答1: After looking, it's seems that HMAC is much faster and better in term of security even if the underlying hash function (SHA1) is broken, which is not the case when using RSA-SHA1. 回答2: In cryptography you normally go for a symmetric scheme - such as HMAC - over an asymmetric scheme - such as RSA for signing - if that is possible within the protocol. In general asymmetric