Questions tagged [cryptography]

Questions relating to cryptographic topics such as encryption/decryption and hashing. (Not for use with trivial ciphers.)

Filter by
Sorted by
Tagged with
2
votes
1answer
2k views

JavaScript xor function

I made simple JavaScript xor function. It accepts string, numeric array and mixed array (char, string, num) as params. It returns string or an array. Returning an array is a must!. All numbers are ...
2
votes
1answer
2k views

Review my Diffie Hellman class

Here is a link to my project, more details regarding the Diffie Hellman Key Exchange using MODP cyclic grous are available here, no ECP currently implemented https://en.wikipedia.org/wiki/...
2
votes
1answer
98 views

kryptein cryptography package for Node.js

I have written a cryptography NPM package called kruptein. The code is also hosted on GitHub. Having used multiple "best practices" with regards to key management, algorithm selection, key size, iv ...
2
votes
1answer
76 views

Crypto for a funny contest with friends

I am participating in a funny crypto contest with my friends. This time, we raised the bar quite a bit. The code below is my take for the constraints we set. Note that on my machine, the code works ...
2
votes
1answer
411 views

Home-grown encryption/decryption function

I know what you are thinking, it's never a good idea to roll your own encryption functions, but I'm doing this for fun and self-learning. I created a function that allows you to send a string as a ...
2
votes
1answer
644 views

Split string into “n” lengths with padding

I quickly wrote a short program to split a string into \$n\$ lengths with variable-character padding: ...
2
votes
1answer
2k views

Decrypting single byte XOR encryption

The code along with the utils module is also at github. If you'd also have any advice on how the whole crate is structured I'd love to hear it. :) ...
2
votes
1answer
82 views

Encrypting a user's file with a key that isn't stored but only known by the user

I want to make some kind of file vault. I want to store encrypted files in a MySQL table, and the key to encrypt/decrypt them is never stored but only known to the user (that's the goal, anyway). The ...
2
votes
2answers
2k views

Simple ActiveRecord attributes encryption in Rails 5+

The task at hand was to ensure that certain columns in the database are encrypted in case the database data is stolen. I have a feeling that a lot can be improved here (naming, DSL, encapsulations) ...
2
votes
1answer
2k views

Signing a String using an identity and trust from a PKCS #12 Bundle

One of the requirements of a third-party SDK I am integrating with is to sign an identifier string with the identity from a p12 certificate. This code loads a p12 certificate from the application's ...
2
votes
2answers
241 views

Intel® TinyCrypt: AES-128/CTR to encryption/decryption of 2D arrays

I need to encrypt/decrypt 2D arrays (double pointers) using AES-128/CTR using Intel TinyCrypt (written in C). The following are two helper methods to simplify the library usage. Any comments would be ...
2
votes
1answer
62 views

Optimizing mcrypt encryption class further

The following is a very simple implementation of an Encryption class using mcrypt whereby the functions encrypt and ...
2
votes
1answer
1k views

User name and password validation in a MVP application

In a WinForms application I'm doing the password validation as follows: When the user presses the OK button after entering username and password, an event will be fired and the listener in the ...
2
votes
1answer
771 views

Critique of FilterInputStream and FilterOutputStream classes

I'm working my way through The Java Programming Language, Fourth Edition - The Java Series. This is Exercise Exercise 20.3: Create a pair of Filter stream classes that encrypt bytes using any ...
2
votes
1answer
44 views

Encrypts using AES GCM for data with limited visibility and long rest

This is the third iteration of my venture on creating an encryption/decryption solution. I asked a question here, which led to this question here, which led to this answer here, which led me to ...
2
votes
1answer
131 views

Vigenère decoder/encoder in Python (using matrix)

I made an encoder/decoder for the Vigenère cipher. This one is using a table, not the remainder technique. Please let me know what you think can be done to improve performance, etc. ...
2
votes
1answer
5k views

AES Encryption/Decryption with key

Is this the best way to encrypt/decrypt data? And Is it good to store Generated InitVector and CipherText in database as Base64 String which is converted from byte[]? ...
2
votes
1answer
60 views

Sign an EC2/S3 URL Version 2

Follow up on previous review: Sign an EC2/S3 URL I have fixed the previous comments. I have also added the code needed to sign HTTP header fields as part of the request. ...
2
votes
1answer
236 views

Bash - script to encrypt pdf files using pdfencrypt

I wrote a small script to get around the issue when using pdfencrypt on the command line the password is always echoed as well as being saved to the 'history'. <...
2
votes
1answer
412 views

Encryption in C#

I have got to my self these two functions (Encryption and Decryption): ...
2
votes
1answer
2k views

Making AES encryption in Go just a little easier

AES encryption in Go is already pretty simple, Gencrypt is a package that acts as a wrapper around Go's standard packages used for AES encryption to make it even more simple. https://gitlab.com/...
2
votes
1answer
102 views

Vector-based Null Cipher

Continuing with my series of cipher programs, I hastily wrote a null cipher program, and I was wondering how it could be improved: ...
2
votes
3answers
767 views

More efficient columnar transposition decryption

Below, I have created a rudimentary script to decipher a columnar transposition. I am wondering if there is a more efficient way to determine the number of the rows in a column? Also, is there a way ...
2
votes
1answer
1k views

Ensuring client IDs are unique

I'm writing a node.js application that involves handling clients based on their ID without any real way of confirming that the ID a client says it has is its actual ID. That is, it's possible for a ...
2
votes
1answer
1k views

RC4 implementation in Go

I'm new to Go, and as a learning project I've been implementing RC4, attempting to follow pseudo-code in the Wikipedia links (and trying not to look at the far-superior version in the crypto package). ...
2
votes
1answer
887 views

Better ways of solving the substitution cipher puzzle

here is the puzzle description Your task is to decode messages that were encoded with substitution ciphers. In a substitution cipher, all occurrences of a character are replaced by a different ...
2
votes
1answer
339 views

Cipher and passphrase classes using Java cryptography

I use some basic cryptography in a project of mine. Because I want my application to run cross-platform and because it seems pretty sophisticated I decided to go with the Java Cryptography ...
2
votes
0answers
60 views

XXTEA encryption implemented in modern C++

At the company i work we have a system where an user is presented with a question and some alternatives to choose from. The question and answers are generated at runtime. In order to simplify the ...
2
votes
0answers
39 views

Difference distribution table for DES

This is my DDT (for DES) code. I just wonder how to be more efficient... I've just started cryptography and I'm not good enough. ...
2
votes
0answers
18 views

RC4 in Sinclair BASIC; Working around one-indexed arrays

This is a program written in Sinclair BASIC (48 BASIC) for the Sinclair ZX Spectrum. It uses a hardcoded key (null right now) as seen in the bottom and outputs a stream of integers generated with RC4. ...
2
votes
0answers
206 views

Python RSA/DSA File Cryptography, Key Generation, Key Protection

I have forked a previous version of my script, critiqued here: Generate public/private keys, encrypt, decrypt, sign, verify This program allows you to encrypt and decrypt raw files using RSA keys ...
2
votes
1answer
70 views

Generating user ids on a random forum website

Will this code be random enough to generate user ids for a website where people can create posts? Would there be a better method other than running this function and validating it doesn't exist in the ...
2
votes
0answers
321 views

Python2.7 Some xor fun

After doing the Cryptopals challanges, which I found scrolling through codereview, and finally being able to solve set1 challenge 6. I decided to have a little xor fun, and make an automated xor ...
2
votes
0answers
1k views

ISO mode encryption/decryption with BouncyCastle

I need to implement an ISO-mode encryption/decryption library in C# using BouncyCastle. In this mode, users only need to exchange their RSA public keys to securely communicate. Operation is as follows:...
2
votes
0answers
311 views

Java Crypto library number of padding bytes using PKCS5Padding

I have implemented AES encryption in Java using the following function. What puzzles me is the number of padding bytes added using the PKCS5Padding method. For example, when calling the following ...
2
votes
0answers
594 views

Hashing a SecureString in C#

In .NET, the SecureString type exists to prevent leaking secrets in memory. I want to create a hash from the contents of a SecureString, without putting the contents in memory in a place where I can't ...
2
votes
0answers
685 views

Wrapper/abstraction for encryption and decryption using OpenSSL

I am a beginner when it comes to cryptography and OpenSSL. I have written a short wrapper of some functions in OpenSSL as well as a test of this wrapper, copied below. Specifically, this code is ...
2
votes
0answers
41 views

Symmetric decryption with javax.crypto

I'm trying to determine if this code could be a memory hog with huge files. Can anyone tell me if there is anything I can do to make this more memory efficient, or is this how java.crypto works? <...
2
votes
0answers
176 views

Locally encrypt/decrypt credentials

I wrote some code to encrypt and decrypt some user credentials for services that a locally run application needs to work. I get a password from the user, use it to stretch a key via Scrypt, and then ...
2
votes
0answers
768 views

Converting [UInt32] -> [UInt8] -> [[UInt8]]

I am trying to speed up my current implementation of a function that converts [UInt32] to a [UInt8] which in turn is split up ...
2
votes
0answers
2k views

Simple Java Encryption/Decryption

I am a beginner at Java programming, and I'm always curious about how to make code more efficient or learn what I am doing wrong. I just started learning about cryptography, and this is a simple ...
2
votes
0answers
1k views

LockBox TwoFish string encryption and decryption

I'm using TurboPower LockBox for the first time, and using the TwoFish algorithm to first encrypt a password, and later retrieve the password by decrypting the generated hash. I would like to know ...
2
votes
0answers
359 views

Simple encryption with PHP 5.5

I want to do simple encryption using PHP 5.5. By “simple” I mean I want to use native PHP functions. I have created this code that works, can it be improved? It's to encrypt/decrypt strings and binary ...
2
votes
0answers
155 views

AES256 + HMACSHA256 'secretbox'

I aim to create a few primitives for creating AES256-then-HMACSHA256 secured session state through cookies. What I've considered: HMAC instead of plain sha to avoid hash extension attacks input ...
2
votes
0answers
2k views

Encrypt texts, with saved password using pycrypto

I have the code bellow, which is supposed to be used inside a larger program. Please see notes about the requirements below the code. ...
1
vote
4answers
2k views

Java class to compute and get a MD5 hash as a string

Here is my class file to compute MD5 hashes on a file. I wanted to be able to easily calculate them without having to create a lot of overhead in the code using the class. Can anyone tell me a list ...
1
vote
2answers
1k views

Is my Encryption Module Secure? [closed]

I have a simple encryption module that is used to "encrypt" a text file because it contains some passwords. I only need to encrypt it because I need those passwords in my program (they are used to ...
1
vote
2answers
335 views

Encryption scripts using the module cryptography

Its meant to password protect python scripts by using encryption It should use os.urandom(40)'s output in hex as the salt. The kdf (cryptography.io) is using Scrypt ...
1
vote
3answers
1k views

Encryption algorithm using CTR mode

I am using CTR mode (it is a cipher in itself) in this code. I just wanted to see what you thought about it before I finish it. (Yes, I know that the plaintext length and key length must be highly ...
1
vote
1answer
195 views

Some kind of encryption in C++

It's my university task. Can I get some opinions on it? ...