Function checkAndCreate
        Check if an object exists and create it if not

        @param key: The targeted object
        @param payload: The targeted object description
        @return RETURN: The id of the object
972522
def checkAndCreate(self, key, payload):
        
        if key not in self:
            if 'templates' in payload:
                templates = payload.pop('templates')
            self[key] = payload
            self.reload()
        return self[key]['id']
207890
function createKeyObject (rawKeyObject, finalPublicKey = null) {
  const created = rawKeyObject.created ? dateToUnixTimestamp(rawKeyObject.created) : null;
  const revoked = rawKeyObject.revoked ? dateToUnixTimestamp(rawKeyObject.revoked) : null;
  const expires = rawKeyObject.expires ? dateToUnixTimestamp(rawKeyObject.expires) : null;
  // backcompat for v2 alpha
  let publicKey = finalPublicKey;
  if (!finalPublicKey) {
    const publicKeyTemp = rawKeyObject.id || rawKeyObject.publicKey;
    publicKey = publicKeyTemp.replace('ecdsa-koblitz-pubkey:', '');
  }
  return new Key(publicKey, created, revoked, expires);
}
323650
def create(self, key, *args, **kwargs):
        
        instance = self._class(key, *args, **kwargs)
        self._events.create.trigger(list=self, instance=instance, key=key, args=args, kwargs=kwargs)
        return self.insert(instance)
880305
private String getPayLoad(Key key, Application app) {
        if (app == null) {
            return EMPTY_PAYLOAD;
        }

        EncoderWrapper encoderWrapper = serverCodecs.getEncoder(key.getType(), key.getEurekaAccept());
        try {
            return encoderWrapper.encode(app);
        } catch (Exception e) {
            logger.error("Failed to encode the payload for application {}", app.getName(), e);
            return "";
        }
    }
1234087
def create_token(key, payload):
  
  token = hmac.new(key)
  token.update(json.dumps(payload))
  return token.hexdigest()
482944
def key_exists(self, key):
        
        assert isinstance(key, str)
        cursor = self.conn.cursor()
        with contextlib.closing(cursor):
            cursor.execute('SELECT COUNT(*) FROM events WHERE uuid=?', (key,))
            res = cursor.fetchone()
            count = res[0]
        if count == 0:
            return False
        else:
            assert count in (0, 1), \
                "Duplicate event ids detected: {0}".format(count)
            return True
529020
def unique(self, key=None):
        
        if key is None:
            seen = set()
            seen_add = seen.add

            return self.__class__([x for x in self.items if not (x in seen or seen_add(x))])

        key = self._value_retriever(key)

        exists = []

        def _check(item):
            id_ = key(item)
            if id_ in exists:
                return True

            exists.append(id_)

        return self.reject(_check)
1363816
function( signature, input, key ) {

    var verifier = crypto.createVerify( this.algorithm + this.bits )

    return verifier.update( input )
      .verify( key, signature )

  }
635560
@Override
    public final Object createEntry(Object key) throws Exception {
        final A data = threadData.get();
        return this.createEntry(key, data);
    }
938939
function( signature, input, key ) {

    if( !Buffer.isBuffer( input ) )
      throw new TypeError( 'Input must be a buffer' )

    if( !Buffer.isBuffer( signature ) )
      throw new TypeError( 'Signature must be a buffer' )

    if( this.type === 'PLAIN' )
      return signature.length === 0

    if( !Buffer.isBuffer( key ) )
      throw new TypeError( 'Key must be a buffer' )

    switch( this.type ) {
      case 'HS': return this._verifyHMAC( signature, input, key )
      case 'RS': return this._verifyRSA( signature, input, key )
      case 'ES': return this._verifyECDSA( signature, input, key )
      default:
        throw new Error( 'Unsupported type "' + this.type + '"' )
    }

  }
617780
NotificationHandlerNodeSubregistry getOrCreateSubregistry(final String key) {
        for (;;) {
            final Map<String, NotificationHandlerNodeSubregistry> snapshot = childrenUpdater.get(this);
            final NotificationHandlerNodeSubregistry subregistry = snapshot.get(key);
            if (subregistry != null) {
                return subregistry;
            } else {
                final NotificationHandlerNodeSubregistry newRegistry = new NotificationHandlerNodeSubregistry(key, this);
                if (childrenUpdater.putAtomic(this, key, newRegistry, snapshot)) {
                    return newRegistry;
                }
                // otherwise, retry the loop because the map changed
            }
        }
    }
441500
protected Document byId(final K key) {
        if (key != null) {
            return new Document(ID, key.toString());
        } else {
            throw new NullPointerException("Key must not be null");
        }
    }
655376
function getMappedKey (key, create) {
        allKeyMap = getAllKeys();

        if (create && !(key in allKeyMap)) {
            var newKey = ("uD" + _UNIQUE_ID++);
            setMappedKey(newKey, key);

            return newKey;
        } else {
            return allKeyMap[key];
        }
    }
344171
function Key( options ) {

  if( !(this instanceof Key) )
    return new Key( options )

  this.version = null
  this.type = 'rsa-sha256'
  this.flags = null
  this.granularity = null
  this.hash = null
  this.notes = null
  this.service = null
  this.key = null

  var self = this

  if( options != null ) {
    Object.keys( options ).forEach( function( k, v ) {
      if( Key.fields.indexOf( k ) !== -1 ) {
        self[ k ] = options[ k ]
      }
    })
  }

}
1330053
public Payload add(String key, String value) {
    getData().put(key, value);
    return this;
  }
257236
@Override
  public String getOrCreateForKey(String key) {
    return uuidsByKey.computeIfAbsent(key, k -> Uuids.create());
  }
248378
private Bucket getOrCreateBucketForKey(Object key)
    {
        int index = getBucketIndexForKey(key);

        // Double-checked locking.  Safe since buckets do not initialize any state
        // until they are synchronized by the caller.                      d739870
        Bucket bucket = buckets[index];
        if (bucket == null)
        {
            synchronized (bucketLock)
            {
                bucket = buckets[index];
                if (bucket == null)
                {
                    // If this is to be a cache of EJB Wrappers, then create Wrapper
                    // specific buckets, that hold EJSWrapperCommon objects,
                    // otherwise create generic BucketImpl.                   d195605
                    bucket = wrappers ? new WrapperBucket(this) : new BucketImpl();
                    buckets[index] = bucket;
                }
            }
        }

        return bucket;
    }