• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    Java
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cryptography Android application code samples / cipher collection for app users

Cryptography Image 1

Cryptography

This repository will slowly get more and more cryptography code samples written in Java. Methods are related to Cryptography android application cipher method collection. Point of this repository is that users can find everything in one place, modify code, play with these methods in any way they want and this way learn how ciphers worked in the past and how they work these days. In short words this repository is meant to be educational.

This repository is part of this Android application: Google Play - Cryptography

Feel free to contribute or open issues!

Table of contents


Ciphers

Cipher (or cypher) is an algorithm for performing encryption or decryptionβ€”a series of well-defined steps that can be followed as a procedure. Encryption is the process of encoding information. This process converts the original representation of the information, known as plaintext, into an alternative form known as ciphertext.

Adfgvx
AES - 128 / 192 / 256
Anubis - 320
ARIA
Atbash
Autokey
Bacon
Beaufort
Blowfish
Caesar
CAST - 5 / 6
Chaocipher
Elgamal
Gronsfeld
IDEA
Keyword
Khazad - 128
LC4 / LS47
Navajo
OneTimePad | Vernam
Playfair
Porta
Rail fence
RC - 2 / 4 / 6
Scytale
Vigenere
Elliptic Curve
VIC

Converters

Converters converts input from representation system A to representation system B and vice versa.

BinaryDecimal
BinaryHex
BinaryInteger
BinaryText
Compliment

Encoding

Encoding is used to represent data in ASCII string format by translating the data into selected encoding representation.

A1z26
Adaptive Huffman
Base16
Base32
Base58
Base64
Base85
Base91
Huffman
Morse
PEM
Pig Latin
RLE
Koblitz
VIC Sequencing

Hashes

A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes.

ADLER - 32
Blake2b - 160 / 256 / 384 / 512
CRC - 8 / 16 / 24 / 32 / 64
ELF - 32
FCS - 16
HAS - 160
KECCAK - 256 / 384 / 512
Kupyna - 256 / 384 / 512
MD - 2 / 4 / 5
PBKDF2
RIPEMD - 128 / 160 / 256 / 320
SHA - 0 / 1 / 224 / 256 / 384 / 512
SHA2 - 224 / 256 / 384 / 512
SHA3 - 224 / 256 / 384 / 512
Skein - 256 / 512 / 1024
SM3
SUM - 8 / 16 / 24 / 32
TIGER - T / 2 / 128 / 160
WHIRLPOOL - 0 / 1 / W
XOR - 8

Random

Random generation is a process which, often by means of a random number generator (RNG), generates a sequence of numbers or symbols that cannot be reasonably predicted better than by a random chance.

Dummy - Bytes
Secure Random - Strong / SHA1PRNG

Certificates

In computer security, an attribute certificate, or authorization certificate (AC) is a digital document containing attributes associated to the holder by the issuer. When the associated attributes are mainly used for the purpose of authorization, AC is called authorization certificate. AC is standardized in X.509. RFC 5755 further specifies the usage for authorization purpose in the Internet.

X509

Signatures

mathematical scheme for verifying the authenticity of digital messages or documents. A valid digital signature, where the prerequisites are satisfied, gives a recipient very strong reason to believe that the message was created by a known sender (authentication), and that the message was not altered in transit (integrity).

JWT - Json Web Token

Installation

  1. Download and install eclipse: https://www.eclipse.org/downloads/ or any other IDE.
  2. Download project source code by either cloning it with Git or by Clone or download menu Download ZIP option.
  3. Open project in Eclipse File - Open projects from File System...
  4. Navigate to /src - cryptography - Ciphers.java and start play with it. Rest of the folder structure has method specific code and tests files for running automated tests.

I warmly recommend watching basic Eclipse tutorials if you are new to the topic.

Running tests

Automatically

  1. Make new branch.
  2. Push changes. (tests will be run with each push)
  3. Open pull request.
  4. Later tests are run by Github Actions workflow (./.github/workflows/Tests.yml).

Manually

  1. Right click on TestRunner.java
  2. Click Coverage As
  3. Select 1 Java Application
  4. If everything is fine result is Tests success: true

External libraries

commons-codec-1.10.jar

  • Included for Base32 and Base64 encoding methods.

jacksum-1.7.0 (jacksum.jar)

core-1.58.0.0.jar | prov-1.58.0.0.jar | bcpg-jdk15on-1.58.0.0.jar | bcpkix-jdk15on-1.58.0.0.jar (Spongy Castle)

bcprov-jdk15on-170

  • BouncyCastle signed cryptography provider

bcpkix-jdk15on-170

  • BouncyCastle signed cryptography provider

org.junit_4.13.0.v20200204-1500.jar | core-1.3.0.jar

  • JUnit 4 jar and hamcrest core for Github Actions based test runs.

Adding external library

Every time new external jar library is added, it must be also added to build.xml in a block seen below as example

<path id="Cryptography.classpath">
    <pathelement location="bin"/>
    <path refid="JUnit 4.libraryclasspath"/>
    <pathelement location="jar/commons-codec-1.10.jar"/>
    <pathelement location="jar/jacksum.jar"/>
    <pathelement location="jar/core-1.58.0.0.jar"/>
    <pathelement location="jar/prov-1.58.0.0.jar"/>
    <pathelement location="jar/bcpkix-jdk15on-1.58.0.0.jar"/>
    <pathelement location="jar/bcpg-jdk15on-1.58.0.0.jar"/>
    <pathelement location="jar/org.junit_4.13.0.v20200204-1500.jar"/>
    <pathelement location="jar/core-1.3.0.jar"/>
    <pathelement location="jar/bcprov-jdk15on-170"/>
    <pathelement location="jar/bcpkix-jdk15on-170"/>
</path>

Notes

Some ciphers or parts of ciphers originate from web sites, tutorials, repositories or other sources. There's unfortunately no links to original references.

Troubleshooting

Noticed at Mac with jdk1.8.0...

[java.security.InvalidKeyException: Illegal key size or default parameters]>

this could be due to crypto policy being limited at java config. To change this, go to:

cd /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/jre/lib/security/
sudo nano java.security

and uncomment out crypto.policy=unlimited: Cryptography Image 1

Following did same trick but from code, so used this one:

import java.security.Security;
public class SomeClass {
	public static void main(String[] args) {
        Security.setProperty("crypto.policy", "unlimited");
    }
}

Contributions

Rules?

  • Please, write tests if you make something new.

Found problem?

  • Open issue or make new branch and create pull request when problem is fixed.

Want to optimize code?

  • You are free to optimize code, make new branch and create pull request when ready.

Authors

Contributors

  • Saurav Kumar - *Added Morse, Huffman, Compliment, Koblitz, EllipticCurve, VICsequencing, VIC * - SKR301

License

See repo license section or license file.

More Repositories

1

open-intelligence

Creepy stalking tool to process security camera motion triggered images and sort seen objects in different categories, detect license plates and faces. Has PWA ready web front end. Meant to make property monitoring faster without need to watch video recordings.
TypeScript
164
star
2

poker-pocket-backend

Nitramite Poker Pocket light weight NodeJS poker game backend
JavaScript
31
star
3

apcupsd-monitor

Android app for monitoring Eaton and APC UPS devices statuses and view events (UPS => Uninterruptible power supply) supports APC network management card, synology upsc
Java
22
star
4

poker-pocket-web-client

Nitramite Poker Pocket poker game web front end
JavaScript
15
star
5

radiation-detector-arduino

Arduino code for Nitramite Nuclear Radiation Detector Android application.
C++
11
star
6

paketin-seuranta

Privacy preserving parcel tracking application for Android supporting multiple parcel courier companies. App is targeted in Finnish market. Standalone app, no private backends, tracking or overkill infrastructure. No ads or paid content.
Java
11
star
7

nx100-remote-control

Motoman NX100 industrial robot remote control ability research and development
Python
8
star
8

hikvision-video-audio-extractor

Hikvision recording video audio extractor component for Open Intelligence
C#
8
star
9

yagi-pro

Yagi Uda Pro calculate Yagi antenna with 3D printable parts
TypeScript
4
star
10

node-express-orm-typescript-template

Simple Node.js, TypeScript, Express, JWT, Sequelize Orm API, Schedule application template for fast need with proper documentation
TypeScript
4
star
11

hash-numbers

Turn incrementing number into harder to guess numbers but with reversible way. Designed to support different algorithms.
TypeScript
3
star
12

price-poller

Product price poller, email notifications when price is lower than latest value
JavaScript
2
star
13

muh-ilmava

Vallox MUH Ilmava home ventilation machine Arduino temperature and humidity sensing hacks to plot recorded data with Apache Superset. Can determine if Sauna is used, when food is cooked, does MUH heating element still work, what outside temperature actually is and all about humidity.
C++
2
star
14

nitspec

NitSpec is a gun shot augmentation controller application which controls gun trigger via servo and calculates projectile fly path automatizing shots. Uses few sensors for calculation. This is meant for air rifles.
Java
2
star
15

banking-ws

Node.js library to construct, validate and make corporate banking web service requests with SOAP. Library helps to create and renew certificates.
TypeScript
2
star
16

nitramite_alpr

Neural network based automatic number-plate recognition module for Open-Intelligence
Python
1
star
17

stock-market-helper

Stock-Market-Helper for monitoring and analysis. Gives decision data for further user actions.
JavaScript
1
star
18

open-intelligence-arduino-client

Small Arduino information display unit for Open Intelligence project
C++
1
star
19

network-scanner

Simple Network Scanner using Evilscan and integrating database based control. Includes small web UI.
JavaScript
1
star
20

noiser-extras

Noiser application extra contents
1
star
21

open-intelligence-android-client

Small Android client for Open-Intelligence meant for SSH tunnel connections on special cases
Java
1
star