Skip to content

OpenSSL RSA Encryption, Decryption, and Key Generation. Java, Php, GoLang Support, Large Data Support.

License

Notifications You must be signed in to change notification settings

MirrorAzureZhang/x-rsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XRSA

OpenSSL RSA Encryption, Decryption, and Key Generation. Java, Php GoLang Support, Large Data Support.

Installation

Php

    composer require williamylian/x-rsa

GoLang

    go get github.com/williamylian/x-rsa

Java

Just Copy XRsa.java to your project

Usage

Php

    $keys = XRsa::createKeys(2048);
    $rsa = new XRsa($keys['publicKey'], $keys['privateKey']);
    
    $data = "Hello, World";
    $encrypted = $rsa->publicEncrypt($data);
    $decrypted = $rsa->privateDecrypt($encrypted);
    $sign = $rsa->sign($data);
    $is_valid = $rsa->verify($data, $sign);

GoLang

    var publicKey *bytes.Buffer = bytes.NewBufferString("")
    var privateKey *bytes.Buffer = bytes.NewBufferString("")
    var xrsa *XRsa

    err := CreateKeys(publicKey, privateKey, 2048)
    if err != nil {
        return
    }
    xrsa, err = NewXRsa(publicKey.Bytes(), privateKey.Bytes())
    if err != nil {
        return
    }

    data := "Hello, World"
    encrypted, _ := xrsa.PublicEncrypt(data)
    decrypted, _ := xrsa.PrivateDecrypt(encrypted)
    $sign = $rsa->Sign(data);
    $is_valid = $rsa->Verify(data, sign);

Java

    Map<String, String> keys = XRsa.createKeys(2048);
    XRsa rsa = new XRsa(keys.get("publicKey"), keys.get("privateKey"));
    
    String data = "hello world";
    String encrypted = rsa.publicEncrypt(data);
    String decrypted = rsa.privateDecrypt(encrypted);
    String sign = rsa.sign(data);
    Boolean isValid = rsa.verify(data, sign);

About

OpenSSL RSA Encryption, Decryption, and Key Generation. Java, Php, GoLang Support, Large Data Support.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 42.2%
  • Java 31.9%
  • PHP 25.7%
  • Batchfile 0.2%