com._8x8.data.repository.EncryptorRepository.java Source code

Java tutorial

Introduction

Here is the source code for com._8x8.data.repository.EncryptorRepository.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com._8x8.data.repository;

import javax.xml.bind.DatatypeConverter;

import org.springframework.stereotype.Repository;

@Repository
public class EncryptorRepository implements IEncryptorRepository {

    @Override
    public String encrypt(String dataToBeEncrypted) throws Exception {
        String encoded = DatatypeConverter.printBase64Binary(dataToBeEncrypted.getBytes());
        return encoded;
    }

    @Override
    public String decrypt(String encryptedData) throws Exception {
        String decoded = new String(DatatypeConverter.parseBase64Binary(encryptedData));
        return decoded;
    }

}