Monday, 21 October 2024

Push html file project on github.io and react js project

This is HTML 

1. Build the design with html and css.

2. Create repo on Github
2.1 repositories should be public
2.2 repositories name is : username.github.io

2.3 push the code on this repo: https://github.com/username/username.github.io

3. GitHub.io only indicates the main branch.

4. Fire up a browser and go to https://username.github.io.


--------------------------------------------------------------------

This is REACT JS

1. npm install gh-pages --save-dev

make sure run this command: npm run build isme koi error and warning nhi ana chahiye    

2. add this line in package.json

{

  "name": "react-app-oct",

  "version": "0.1.0",

  "private": true,

  "homepage": "https://username.github.io/",

// "homepage": "https://username.github.io/github-react-21-oct",  

"dependencies": {}


"scripts": {

    "predeploy": "npm run build",

    "deploy": "gh-pages -d build --repo https://github.com/username/username.github.io.git",

 // "deploy": "gh-pages -d build", pehle iske sath deploy karo nhi to uper wale ke sath

    "start": "react-scripts start",

    "build": "react-scripts build",

    "test": "react-scripts test",

    "eject": "react-scripts eject"

  },

----

ye sab add karne ke baad code ko push karna hai

phit ye run karna hai : npm run deploy


---

ye wali branch deploy hoti hai Gihub per, jb repo per click karoge to waha se "gh-pages" ye wai branch select karni hogi

gh-pages


Check GitHub Pages Settings

  • Go to the GitHub repository https://github.com/username/github-react-21-oct.
  • Ensure the Source is set to gh-pages branch, and save the settings.

Tuesday, 1 October 2024

Asymmetric encryption in Ruby On Rails OR Private Public key encryption

public_key.pem and private.key

public_key_pem = File.read(ENV['LOCAL_PUB_KEY'])

public_key = OpenSSL::PKey::RSA.new(public_key_pem)

data_to_encrypt = "Hello arvind"

encrypted_data = public_key.public_encrypt(data_to_encrypt)

private_key_pem = File.read(ENV['LOCAL_PRI_KEY'])

private_key = OpenSSL::PKey::RSA.new(private_key_pem)

decrypted_data = private_key.private_decrypt(encrypted_data)

---------------------------------------------

public_key.der and private.key

public_key_pem = File.read(ENV['LOCAL_PUB_KEY_DER'])

public_key = OpenSSL::PKey::RSA.new(public_key_pem)

data_to_encrypt = "This is the message to be encrypted"

encrypted_data = public_key.public_encrypt(data_to_encrypt)

private_key_pem = File.read(ENV['LOCAL_PRI_KEY'])

private_key = OpenSSL::PKey::RSA.new(private_key_pem)

decrypted_data = private_key.private_decrypt(encrypted_data)

---------------------------------------------

public_key.cer and private.key

public_key_pem = File.read(ENV['LOCAL_PUB_KEY_DER'])

public_key = OpenSSL::PKey::RSA.new(public_key_pem)

data_to_encrypt = "Rinku"

encrypted_data = public_key.public_encrypt(data_to_encrypt)

private_key_pem = File.read(ENV['LOCAL_PRI_KEY'])

private_key = OpenSSL::PKey::RSA.new(private_key_pem)

decrypted_data = private_key.private_decrypt(encrypted_data)

---------------------------------------------

public_key.cer and private.der

public_cer = File.read('./public_key.cer')

public_key = OpenSSL::PKey::RSA.new(public_cer)

data_to_encrypt = "Rinku k"

encrypted_data = public_key.public_encrypt(data_to_encrypt)

private_der = File.read('./private.der')

private_key = OpenSSL::PKey::RSA.new(private_der)

decrypted_data = private_key.private_decrypt(encrypted_data)

----------------------------------------------------

Hybrid Encryption: Combining Symmetric and Asymmetric Techniques

require 'openssl'

symmetric_key = OpenSSL::Cipher.new('AES-256-CBC').random_key

cipher = OpenSSL::Cipher.new('AES-256-CBC')

cipher.encrypt

cipher.key = symmetric_key

encrypted_data = cipher.update("Rinku") + cipher.final

rsa_public_key = OpenSSL::PKey::RSA.new(File.read('./public_key.cer'))

encrypted_symmetric_key = rsa_public_key.public_encrypt(symmetric_key)

rsa_private_key = OpenSSL::PKey::RSA.new(File.read('./private.der'))

decrypted_symmetric_key = rsa_private_key.private_decrypt(encrypted_symmetric_key)

decipher = OpenSSL::Cipher.new('AES-256-CBC')

decipher.decrypt

decipher.key = decrypted_symmetric_key

decrypted_data = decipher.update(encrypted_data) + decipher.final

puts decrypted_data  # "Secret message"

--------------------------------------------------------------

Asymmetric encryption in Ruby On Rails OR Private Public key encryption

require 'openssl'

require 'base64'

public_key_file = 'public.pem';

string = 'Hello World! fff';

public_key = OpenSSL::PKey::RSA.new(File.read('./public_key.cer'))

encrypted_string = Base64.encode64(public_key.public_encrypt(string))

to

encrypted_string = public_key.public_encrypt(string)  Green wali ek sath kaam karegi

print encrypted_string, "\n"

password = 'boost facile'

private_key = OpenSSL::PKey::RSA.new(File.read('./private.der'),password)

string = private_key.private_decrypt(Base64.decode64(encrypted_string))

to

string = private_key.private_decrypt(encrypted_string)

print string, "\n"