cryptojs

Converting C# Cryptography.Rijndael encryption to Javascript (pref. crypto-js)

孤人 提交于 2019-12-08 12:04:38
问题 I have two system which are sharing a user database, so authentication needs to be the same. The passwords are currently encrypted using C#'s Cryptography.Rijndael (N.B. not RijndaelManaged). Using a custom key and iv (initialisation vector). (CBC mode and Pkcs7 padding) The C# encryption is as follows: Rijndael alg = Rijndael.Create(); alg.Key = key; alg.IV = IV; CryptoStream cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(clearData, 0, clearData.Length);

CryptoJS suddenly stopped working

别来无恙 提交于 2019-12-08 11:24:14
问题 I've been using CryptoJS in a web view on iOS for a while now without issue, however today I am starting to get the error Can't find variable: CryptoJS The links to http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha256.js and http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js seem to have gone. Does anyone know of an alternative location for this? 来源: https://stackoverflow.com/questions/37186896/cryptojs-suddenly-stopped-working

How to generate a SHA256 hash of 32 bytes using nodejs (crypto) in order to avoid bad key size error thrown from tweetnacl.js?

梦想的初衷 提交于 2019-12-08 07:53:28
问题 I am using the crypto module of node.js to generate a SHA256 hash like this: const key = crypto.createHmac('sha256', data).digest('hex'); Now, tweetnacl throws the error: bad key size when the key is passed in the secretbox : nacl.secretbox(data, Rnonc, key); The parameters are converted into Uint8Array since the secretbox requires arguments to be Uint8Array. The error: bad key size is throw from here in tweetnacl since the crypto_secretbox_KEYBYTES is defined as 32 here. The problem is the

How to generate a SHA256 hash of 32 bytes using nodejs (crypto) in order to avoid bad key size error thrown from tweetnacl.js?

不羁岁月 提交于 2019-12-08 07:14:42
I am using the crypto module of node.js to generate a SHA256 hash like this: const key = crypto.createHmac('sha256', data).digest('hex'); Now, tweetnacl throws the error: bad key size when the key is passed in the secretbox : nacl.secretbox(data, Rnonc, key); The parameters are converted into Uint8Array since the secretbox requires arguments to be Uint8Array. The error: bad key size is throw from here in tweetnacl since the crypto_secretbox_KEYBYTES is defined as 32 here . The problem is the key returned from crypto is in not 32 bytes size. I have searched SO and relevant sites, but couldn't

AES-CTR Encrypt in Go and decrypt in CryptoJS

风格不统一 提交于 2019-12-08 03:53:25
I have a problem decrypting text, which is encrypted in Go lang, with CryptoJS. Here is Go code: https://play.golang.org/p/xCbl48T_iN package main import ( "crypto/aes" "crypto/cipher" "encoding/base64" "fmt" ) func main() { key := []byte("1234567890123456") plaintext := []byte("text can be a random lenght") block, err := aes.NewCipher(key) if err != nil { panic(err) } // The IV needs to be unique, but not secure. Therefore it's common to // include it at the beginning of the ciphertext. // BTW (only for test purpose) I don't include it ciphertext := make([]byte, len(plaintext)) iv := []byte{'

base64 Encoder via crypto-js

只愿长相守 提交于 2019-12-08 03:22:35
问题 I want to Encode number to character. How Can I encode to base64 in output? Code: const CryptoJS = require('crypto-js'); function msg() { return '7543275'; // I want to encrypt this number to character } const msgLocal = msg(); // Encrypt const ciphertext = CryptoJS.AES.encrypt(msgLocal, 'password'); // Decrypt const bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'password'); const plaintext = bytes.toString(CryptoJS.enc.Utf8); console.log(plaintext); 回答1: Solved. const CryptoJS =

base64 Encoder via crypto-js

霸气de小男生 提交于 2019-12-06 15:31:23
I want to Encode number to character. How Can I encode to base64 in output? Code: const CryptoJS = require('crypto-js'); function msg() { return '7543275'; // I want to encrypt this number to character } const msgLocal = msg(); // Encrypt const ciphertext = CryptoJS.AES.encrypt(msgLocal, 'password'); // Decrypt const bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'password'); const plaintext = bytes.toString(CryptoJS.enc.Utf8); console.log(plaintext); Solved. const CryptoJS = require('crypto-js'); // OUTPUT console.log(encrypt()); // 'NzUzMjI1NDE=' console.log(decrypt()); // '75322541'

Encrypting with PHP; decrypting with CryptoJS

梦想的初衷 提交于 2019-12-06 14:36:52
问题 I am having some trouble decrypting data using CryptoJS that was encrypted in PHP. Maybe somebody can advise me on where I am going wrong? I am encrypting as follows: Get hashed password Take substring of (0,16) as the key Encrypt (MCRYPT_RIJNDAEL_128) Encode ciphertext as base64 When decrypting I do the same: Get hashed password Take substring of (0,16) as the key Base64 decode the ciphertext Decrypt PHP: public function encrypt($input, $key) { $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL

trying to mock github webhook request, get: “X-Hub-Signature does not match blob signature”

岁酱吖の 提交于 2019-12-06 05:27:20
问题 Here is a little proxy server setup to handle github webhooks: require('dotenv').config(); var http = require('http'); var createHandler = require('github-webhook-handler'); var handler = createHandler({ path: '/webhook', secret: process.env.GIT_WEBHOOK_SECRET }); http .createServer(function(req, res) { handler(req, res, function(err) { res.statusCode = 404; res.end('no such location'); }); }) .listen(8080); handler.on('error', function(err) { console.error('Error:', err.message); }); handler

SHA512 not the same in CryptoJS and Closure

两盒软妹~` 提交于 2019-12-05 21:50:45
I have some troubles with a simple crypto-challenge. I want to do following: getting a url-encoded and base64-encoded value do url-decoding do base64-decoding hash with Sha512 When working with CryptoJS, i use following code: var parameter = "Akuwnm2318kwioasdjlnmn"; var urlDecoded = decodeURIComponent(parameter); var base64Decoded = CryptoJS.enc.Base64.parse(urlDecoded); var hashed = CryptoJS.SHA512(base64Decoded).toString(CryptoJS.enc.Base64); //hashed = "UxupkI5+dkhUorQ+K3+Tqct1WNUkj3I6N76g82CbNQ0EAH/nWjqi9CW5Qec1vq/qakNIYeXeqiAPOVAVkzf9mA=="