cryptography

Python 2.7 The 'packaging' package is required; normally this is bundled with this package

≡放荡痞女 提交于 2019-12-25 07:28:53
问题 I expect this has to do with the cryptography module, but I'm not sure. Traceback (most recent call last): File "<string>", line 11, in <module> File "c:\python27\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\load er\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Python34\Stuff\Encrypt\build\encrypt\out00-PYZ.pyz\pkg_resources", li ne 68, in <module> File "C:\Python34\Stuff\Encrypt\build\encrypt\out00-PYZ.pyz\pkg_resources.exte rn", line 60, in

RSA keys keys static generation

二次信任 提交于 2019-12-25 07:27:24
问题 I'm guiding myself with this answer over here, which explains how to use both AES and RSA. I managed to successfully implement the AES part with an util class in which I use a passphrase to generate keys. This passphrase will not change, the purpose of this is to encrypt a password before encoding it and saving it to a database. Then whenever I need to decrypt this password I can do it with the same passphrase, which should generate the same key. I've got this working. Now my question begins

Can't verify PyOpenSSL signature in C#

拥有回忆 提交于 2019-12-25 07:24:59
问题 I can sign and verify data in PHP using OpenSSL: function generate_signature($privateKey, $data) { $keyData = openssl_get_privatekey($privateKey); openssl_sign($data, $signature, $keyData, OPENSSL_ALGO_SHA256); openssl_free_key($keyData); $sigText = base64_encode($signature); return $sigText; } function verify_signature($pubKey, $sigText, $data) { $signature = base64_decode($sigText); $keyData = openssl_get_publickey($pubKey); $ok = openssl_verify($data, $signature, $keyData,

Storing the output of openssl_random_pseudo_bytes in Postgres using php? I get an error: invalid byte sequence for encoding “UTF8”

梦想与她 提交于 2019-12-25 07:22:12
问题 I'm generating a salt using the openssl_random_pseudo_bytes function in php. However, I am unable to store the output into a PostgreSQL database. I get an error: ERROR: invalid byte sequence for encoding "UTF8" Now I realize the encoding of the database in question is set to UTF8, and that the output of the function doesn't match, but what is the correct way of solving this? This is a random salt, and I'm worried that converting it to UTF8 via whatever process will not make it

How to ensure that client created IDs aren't human-meaningful with a hash?

对着背影说爱祢 提交于 2019-12-25 07:19:12
问题 I want to allow untrused clients to create fairly short IDs, but enforce that they aren't human-meaningful (e.g. "l34fa75ljasd" is OK but "canada-is-evil" is not). One approach to doing this would be to have the client create a value, hash it, and then use the hashed value as the ID (first suggested in this question). I'm not sure what the best way to implement this is though. The simplest approach I can think of would be for the client to create a random string, hash it with something like

Using TLS in Android

流过昼夜 提交于 2019-12-25 06:30:47
问题 I'm developing an Android application that communicates with my device(ARM based device with bluetooth module) via bluetooth using TLS(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256). What I considered: javax.net.ssl from Android. Problem is that ephemeral(ECDH E ) encryption keys are starting from API 20 but I need API 11. I didn't find a way to add suite. It seems that this library is strongly related to android version. API versions and overview Bouncycastle(spongycastle) I didn't find a way to use

AES Encryption and Obfuscating IDs

女生的网名这么多〃 提交于 2019-12-25 05:26:15
问题 I was considering hashing small blocks of sensitive ID data but I require to maintain the full uniqueness of the data blocks as a whole once obfuscated. So, I came up with the idea of encrypting some publicly-known input data (say, 128 bits of zeroes), and use the data I want to obfuscate as the key/password, then throw it away , thus protecting the original data from ever being discovered. I already know about hashing algorithms, but my problem is that I need to maintain full uniqueness

AES 128 bit CTR partial file decryption with PHP

余生颓废 提交于 2019-12-25 03:53:32
问题 This is not a duplicate post because I have looked everywhere and I can't find an answer to this. Its about partial decryption. Not full. I have a good knowledge of PHP but little knowledge about cryptography. I know the key and the iv of the crypted file. The file is decrypting fine as whole but the real issue arises when I try to decrypt the partial file from the middle. It decrypts fine when I try to decrypt the first 128kb of the file or 256kb or any length from the beginning of the file.

Explaining functions of Vigenère cipher

对着背影说爱祢 提交于 2019-12-25 02:19:40
问题 i found the following code at http://rosettacode.org for the Vigenère cipher and i would like to undestand it better. Could someone explain me what the single lines of code in function ordA(a) and in function(a) do? function ordA(a) { return a.charCodeAt(0) - 65; } // vigenere function vigenere2(text, key, decode) { var i = 0, b; key = key.toUpperCase().replace(/[^A-Z]/g, ''); return text.toUpperCase().replace(/[^A-Z]/g, '').replace(/[A-Z]/g, function(a) { b = key[i++ % key.length]; return

C# SHA256 Hashing Different To Python Result

谁都会走 提交于 2019-12-25 01:53:17
问题 I'm writing a little program based off of a Python code that I have found. There is a few lines I need help with. It is about hasing a value using SHA256 encryption. The python code is as follows: first = hashlib.sha256((valueOne + valueTwo).encode()).hexdigest() second = hashlib.sha256(str(timestamp) + value).encode()).hexdigest() And when I execute it, my values are as follows: first: 93046e57a3c183186e9e24ebfda7ca04e7eb4d8119060a8a39b48014d4c5172b second: