All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bixuebihui.codec.EncryptDecryptServiceBase64Impl Maven / Gradle / Ivy

package com.bixuebihui.codec;

import java.util.List;
import java.util.stream.Collectors;

/**
 * support one or multiple strings encryption
 */
public class EncryptDecryptServiceBase64Impl implements EncryptDecryptService {
    /**
     * encrypt a string
     * @param str the string to be encrypted
     * @return the encrypted string
     */
    public String encrypt(String str){
        return java.util.Base64.getEncoder().encodeToString(str.getBytes());
    }

    public List encrypt(List list) {
       return list.stream().map(this::encrypt).collect(Collectors.toList());
    }

    /**
     * decrypt a string
     * @param str the string to be decrypted
     * @return the decrypted string
     */
    public String decrypt(String str){
        return new String(java.util.Base64.getDecoder().decode(str));
    }

    public List decrypt(List list) {
        return list.stream().map(this::decrypt).collect(Collectors.toList());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy