Skip to content

Instantly share code, notes, and snippets.

View proteye's full-sized avatar
🏠
Working from home

Ramil Zaynetdinov proteye

🏠
Working from home
View GitHub Profile
@proteye
proteye / rsa.dart
Created July 15, 2018 14:46 — forked from ziizii/rsa.dart
How to generate RSA private/public key pair in Dart with Pointy Castle
import 'dart:html';
import 'dart:math';
import 'dart:typed_data';
import "package:bignum/bignum.dart";
import "package:pointycastle/export.dart";
void main() {
var keyParams = new RSAKeyGeneratorParameters(new BigInteger("65537"), 2048, 5);
@proteye
proteye / rsa_pem.dart
Last active July 25, 2024 10:24
How to encode/decode RSA private/public keys to PEM format in Dart with asn1lib and pointycastle
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";
List<int> decodePEM(String pem) {
var startsWith = [
"-----BEGIN PUBLIC KEY-----",
"-----BEGIN PRIVATE KEY-----",
@proteye
proteye / aes_encryption.go
Created August 28, 2018 13:55
AES encryption/decryption with PBKDF2 key derivation example in Go language
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"errors"
package aeslib
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"errors"
@proteye
proteye / aes_encryption_helper.dart
Created September 5, 2018 10:54
How to AES-256 (CBC/CFB mode) encrypt and decrypt in Dart/Flutter with Pointy Castle
import 'dart:convert';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "./convert_helper.dart";
// AES key size
const KEY_SIZE = 32; // 32 byte key for AES-256
const ITERATION_COUNT = 1000;
@proteye
proteye / scrollbar_visible_always.css
Created May 30, 2019 08:23
Always display the scrollbar - both on mobile devices and macOS
#customScroll::-webkit-scrollbar { width: 4px; height: 4px;}
#customScroll::-webkit-scrollbar-track { background-color: #999;}
#customScroll::-webkit-scrollbar-track-piece { background-color: #ffffff;}
#customScroll::-webkit-scrollbar-thumb { height: 50px; background-color: #666; border-radius: 3px;}
#customScroll::-webkit-scrollbar-corner { background-color: #999;}
#customScroll::-webkit-resizer { background-color: #666;}
@proteye
proteye / KeystoneImageUploader.tsx
Last active August 15, 2024 22:19
Image uploading in KeystoneJS document editor
/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx } from '@keystone-ui/core'
import { FC } from 'react'
import styles from './styles'
import { IImageUploaderProps } from './types'
import useBase from './useBase'
export const ImageUploader: FC<IImageUploaderProps> = (props) => {
@proteye
proteye / single_child_with_keep_position_scroll_view.dart
Last active September 22, 2023 12:30
SingleChildWithKeepPositionScrollView - single child with keep position scroll view in Flutter
import 'dart:math' as math;
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class SingleChildWithKeepPositionScrollView extends StatelessWidget {
/// Creates a box in which a single widget can be scrolled.
const SingleChildWithKeepPositionScrollView({
super.key,
@proteye
proteye / allways_scrollable_with_keep_position_scroll_physics.dart
Created September 22, 2023 12:51
AllwaysScrollableWithKeepPositionScrollPhysics - allways scrollable with keep position scroll physics in Flutter
import 'package:flutter/material.dart';
class AllwaysScrollableWithKeepPositionScrollPhysics extends ScrollPhysics {
final double? Function(double)? _onGetScrollPosition;
const AllwaysScrollableWithKeepPositionScrollPhysics(
{ScrollPhysics? parent, double? Function(double)? onGetScrollPosition})
: _onGetScrollPosition = onGetScrollPosition,
super(parent: parent);
@proteye
proteye / custom_tooltip.dart
Last active October 27, 2023 11:30
Custom animated Tooltip on Flutter
import 'package:flutter/material.dart';
class CustomTooltip extends StatefulWidget {
final String message;
final Widget child;
const CustomTooltip({Key key, this.child, @required this.message})
: super(key: key);
@override