Skip to content

Instantly share code, notes, and snippets.

View Anass-ABEA's full-sized avatar
🎯
Focusing

WhiteBatCodes Anass-ABEA

🎯
Focusing
View GitHub Profile
@Anass-ABEA
Anass-ABEA / RSA.java
Last active November 11, 2021 09:57
helper methods to encode and decode Strings using the Base64 encoder and decoder
import javax.crypto.Cipher;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Base64;
/**
* @author Anass AIT BEN EL ARBI
* <ul>
@Anass-ABEA
Anass-ABEA / RSA.java
Created July 25, 2021 00:27
RSA encryption/Decryption with a specific public/private Key.
import javax.crypto.Cipher;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* @author Anass AIT BEN EL ARBI
* <ul>
* <li>AES/CBC/NoPadding (128)</li>
@Anass-ABEA
Anass-ABEA / RSA.java
Created July 25, 2021 00:33
RSA Decryption Client
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import javax.crypto.Cipher;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
@Anass-ABEA
Anass-ABEA / ApplicationController.java
Created July 25, 2021 00:34
RSA Server Controller ( Encryption )
package com.thexcoders.RSA_server.controllers;
import com.thexcoders.RSA_server.EncryptionManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApplicationController {
@GetMapping("getSecretMessage")
@Anass-ABEA
Anass-ABEA / EncryptionManager.java
Created July 25, 2021 00:35
RSA Encryption Manager from a String public key
package com.thexcoders.RSA_server;
import javax.crypto.Cipher;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
public class EncryptionManager {
private PublicKey publicKey;
import React, {useEffect} from 'react';
import {useState} from "react";
import SideBar from "../../components/sideBar/SideBar";
import FactureBody from "./FactureBody";
import './facture.css'
import axios from "axios";
import {JwtHelper} from "../../helperClasses/jwtHelper";
import {loadFacturesService} from "../../services/FactureServices";
@Anass-ABEA
Anass-ABEA / AES.java
Last active September 20, 2023 05:54
AES ENCRYPTION
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96
*/
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96
@Anass-ABEA
Anass-ABEA / Server.java
Last active August 26, 2021 21:26
Server or AES Encryption
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96
@Anass-ABEA
Anass-ABEA / Client.java
Last active August 26, 2021 21:29
Client for the AES application
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96