Optimization and Testing of Cryptographic Algorithms