package com.utopiaindustries.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.security.SecureRandom;
import java.util.Base64;


@Service
public class CryptographyService {

    private final Logger logger = LoggerFactory.getLogger(CryptographyService.class.getSimpleName());

    @Value("${ctp.cipher.key}")
    private String cipherKey;

    @Value("${ctp.cipher.seed-value}")
    private String seedValue;

    public String generateRandomString( int length ) {
        String allowedCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        SecureRandom random = new SecureRandom();
        StringBuilder builder = new StringBuilder( length );
        for ( int i = 0; i < length; i++ ) {
            int index = random.nextInt( allowedCharacters.length() );
            char randomChar = allowedCharacters.charAt( index );
            builder.append( randomChar );
        }
        return builder.toString();
    }


}
