Skip to content

Instantly share code, notes, and snippets.

View faheemsharif-me's full-sized avatar

Muhammad Faheem Sharif faheemsharif-me

View GitHub Profile
@faheemsharif-me
faheemsharif-me / find_duplicate_number.py
Created September 19, 2023 23:05
Find Duplicate Number in Python, Time Complexity 0(N), Space Complexity 0(N)
class Solution(object):
def findDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
for i in range(len(nums)):
if nums[abs(nums[i])] < 0:
return abs(nums[i])
nums[abs(nums[i])] = -nums[abs(nums[i])]
@faheemsharif-me
faheemsharif-me / CryptionHandler.kt
Created August 23, 2022 03:47
KMS Encryption/Decryption - Encryption and Decryption of KMS using Kotlin
package com.example.util
import com.amazonaws.regions.Regions
import com.amazonaws.services.kms.model.DecryptRequest
import com.amazonaws.services.kms.AWSKMSClientBuilder;
import com.amazonaws.services.kms.model.EncryptRequest;
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import java.util.*
@faheemsharif-me
faheemsharif-me / kms_decryption.py
Last active August 8, 2023 13:55
KMS Decryption with Python - Decrypts Base64 Encoded Cipher Text to Plaintext
import base64
import boto3
from botocore.exceptions import ClientError
import logging
AWS_REGION = 'us-east-1'
kms_client = boto3.client("kms", region_name=AWS_REGION)
@faheemsharif-me
faheemsharif-me / kms_encryption.py
Created August 23, 2022 03:38
KMS Encryption with Python - Encrypt Plain text with KMS and encodes the Cipher Text to Base64
import base64
import boto3
from botocore.exceptions import ClientError
AWS_REGION = 'us-east-1'
kms_client = boto3.client("kms", region_name=AWS_REGION)
def encrypt(secret, key_id):
try: