Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Simple encryption and decryption #93

Open
pwablito opened this issue Oct 21, 2021 · 1 comment
Open

Simple encryption and decryption #93

pwablito opened this issue Oct 21, 2021 · 1 comment

Comments

@pwablito
Copy link

I am trying to use the signal library to make a very simple command line program to encrypt a message and print out the results so that I can then easily decrypt the message on the same system without sending anything back and forth through a server. What is the easiest way to do this? Anywhere I could look that this has already been done?
Thanks in advance for any help anyone can offer!

@tomiamao
Copy link

tomiamao commented Nov 24, 2021

this should be simple...from the readme, do the following:

SessionStore      sessionStore      = new MySessionStore();
PreKeyStore       preKeyStore       = new MyPreKeyStore();
SignedPreKeyStore signedPreKeyStore = new MySignedPreKeyStore();
IdentityKeyStore  identityStore     = new MyIdentityKeyStore();

// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
                                                   identityStore, recipientId, deviceId);

// Build a session with a PreKey retrieved from the server.
sessionBuilder.process(retrievedPreKey);

SessionCipher     sessionCipher = new SessionCipher(sessionStore, recipientId, deviceId);
CiphertextMessage message      = sessionCipher.encrypt("Hello world!".getBytes("UTF-8"));

deliver(message.serialize());

What you need to provide are the stores' implementation i.e sessionStore, preKeyStore, signedPreKeyStore & identityStore.

Implement the deliver method to send the encrypted bytes wherever you want

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants